home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-12-17 | 42.6 KB | 1,091 lines | [TEXT/MPS ] |
- #
- # ****************************************************************************
- #
- # File Name: TCS.Lib
- #
- # Contains: Library used for tracking and logging Test Case completion and success/failure.
- #
- # Written by: Kevin Avoy, Ken Landreth, Michael Leong, Gil Spencer et al
- #
- # Copyright: © 1993 by Apple Computer, Inc., all rights reserved.
- #
- # ****************************************************************************
- # C h a n g e H i s t o r y (most recent first):
- # ****************************************************************************
- #
- # Vers Date Author Description
- # ---- -------- ------ ---------------------------------------------
- # <1.1.11> 12/17/93 KTA Some references to gTestCaseLoggingMethod were not declaring
- # the variable to be global.
- # <1.1.10> 12/16/93 KTA Changed the way we handle exception, changed gFileToolOutput to
- # gTestCaseLoggingMethod
- # <1.1.9> 12/13/93 KTA Added ClearStack() task, and changed the way we handle
- # exceptions.
- # <1.1.7> 12/3/93 KTA ApplicationVerification() if gAppTitle = 'Unknown' turn gAppVerify off.
- # <1.1.6> 12/3/93 KTA Logical and physical memory are now reported in bytes, also
- # added SystemArch.
- # <1.1.5> 12/2/93 KTA Removed isOff, IsOn, VirtualMemory, notAvail, etc
- # <1.1.4> 12/2/93 KTA Added SystemArchitecture to Suite header. Added
- # gSuiteFooterHook, moved call to ApplicationVerification() so it
- # would be called when gDBLogging is off, Added gTCSStartHook1.
- # <1.1.3> 11/24/93 NAGA change "TCS [" to "TEST CASE ["
- # <1.1.2> 11/24/93 NAGA In LogTCSRecord() change TCSDescription to TCDesc
- # 1.0.119> 9/30/93 KTA TCSEnd() - pTCSVal no longer defaults to 'NA' and all fields
- # which exist will printed in gNoteBook = 2.
- # 1.0.118> 9/30/93 KTA PrintTCSRecord() - Fixed a bug where pTCSVal wouldn't print if
- # is was an integer.
- # 1.0.117> 9/23/93 KTA Moved gPreFlight to InitGlobals() and deleted gLaunchReqs, also
- # fixed problem where ApplicationVerification() wasn't working.
- # 1.0.116> 9/23/93 KTA LogSuiteHeader() - Commented out Desc field.
- # 1.0.115> 9/22/93 KTA Call the gExceptionHandler task reference instead of calling the
- # task directly.
- # 1.0.114> 9/20/93 KTA ApplicationVerification() - Retry counter was decremented and it
- # should have been incremented.
- # 1.0.113> 9/14/93 KTA WriteTCSRecord() - If trouble with Filetool turn off
- # FileToolOutput. ApplicationVerification() -If gAppTitle
- # is not defined turn off Application Verification
- # 1.0.112> 9/13/93 KTA ExceptionHandler() - changed TimeOut values,
- # ApplicationVerification() - intl - regular expressions errors.
- # 1.0.111> 9/13/93 KTA Updated TestLevel specification.
- # 1.0.110> 9/2/93 KTA Not writing to string 'FileTool output' to prefs file anymore.
- # <1.0.19> 9/1/93 KTA Changed all calls to VU built in task Exit to call the task
- # reference gExitVu instead.
- # <1.0.18> 9/1/93 KTA Updated task headers and parameters.
- # <1.0.17> 8/25/93 KTA Added support for parity checking the TCS stack.
- # <1.0.16> 8/23/93 KTA Realigned fields in output, fixed TCSPassed.
- # <1.0.15> 8/20/93 KTA TCSStart() - If TCSAttempted is undefined call InitTCSLogging().
- # <1.0.14> 8/20/93 KTA Changed the return for ReadLine2, so had to update how the
- # returnvalue was being used.
- # <1.0.13> 8/20/93 KTA Added LogSuiteHeader(), LogTCSRecord(), InitTCSLogging(), to
- # support FileTool output of Phoenix data.
- # <1.0.12> 8/9/93 KTA Support for new Pheonix data format.
- # <1.0.11> 8/2/93 KTA CleanAbort() - Removed gExitFlag.
- # <1.0.10> 8/2/93 KTA CleanAbort() - Added gExitFlag.
- # <1.0.9> 7/30/93 KTA TCSEnd() - Changed DialogHandler() call and added gTCSEndHook1.
- # <1.0.8> 7/20/93 KTA Bug Fix: failreason was being reinitialized improperly. See
- # TCSEnd().
- # <1.0.7> 7/15/93 KTA Added TCSExpCount: See SuiteEnd()
- # <1.0.6> 7/6/93 KTA If gDBLogging is not set TCSEnd will not do anything.
- # <1.0.5> 6/8/93 NAGA unmark tasks that are not published
- # <1.0.4> 5/21/93 NAGA Adding header and porting old files to follow new standards
- #
- # ****************************************************************************
- #
-
- ########################################################################
- # External libraries
- #=======================================================================
- Libraries "Utility.lib","Gestalt.Lib","UserInterface.Lib", "FileTool.Lib", "String.Lib", "OutPut.Lib";
-
-
-
- #########################################################################
- # InitTCSLogging(pSetupFileToolOutput)
- #========================================================================
- # Author: Kevin Avoy (x4-5604)
- # Description: Initializes globals and <Constants> necessary for generating
- # database records known as TCS (Test Case Specification) records.
- # Parameters: pSetupFileToolOutput - Boolean flag which indicates whether or not
- # to set up the output file for logging TCS output.
- # This requires the FileTool to exist on the Host.
- # Returns: Nothing
- # Examples: InitTCSLogging(0);
- # Assumptions: None
- #========================================================================
- # History:
- #
- #########################################################################
- TASK InitTCSLogging(pSetupFileToolOutput := 0)
- begin
- if(pSetupFileToolOutput)
- SetUpOutput(1);
-
- global gTCSList := {}; # TCS Stack
- global gExceptionHandler := task ExceptionHandler;
- global gExHandling := 1;
- global gDialogHandling := 1;
-
- ############## TCS Globals ############
- global kTCSetDefault := "UnknownSet";
- global kTCTypeDefault := "Compatibility";
- global kTCOwnerDefault := "SPECS&L";
- global kTCSetLaunch := "Launch";
- global kTCSetQuit := "Quit";
- global kTCSetSFSave := "SFSave";
- global kTCSetRevertDoc := "RevertDoc";
- global kTCSetOpenDoc := "OpenDoc";
- global kTCSetNewDoc := "NewDoc";
- global kTCSetScrapBook := "ScrapBook";
- global kTCSetFont := "Font";
- global kTCSetPageSetup := "PageSetup";
- global kTCSetUIWindowDrag := "UIWindowDrag";
- global kTCSetUIWindowClose := "UIWindowClose";
- global kTCSetUIWindowScroll := "UIWindowScroll";
- global kTCSetUIWindowSize := "UIWindowSize";
- global kTCSetUIWindowMiscOp := "UIWindowMiscOp";
- global kTCSetAboutBox := "AboutBox";
- global kTCSetAppSetup := "AppSetup";
- global kTCSetDraw := "Draw";
- global kTCSetPalettePicker := "PalettePicker";
- global kTCSetToolPalette := "ToolPalette";
-
- global TCSAttempted := 0;
- global TCSPassed := 0;
- global TCSNotAvail := 0;
- global TCSExpCount := 0;
- end;
-
-
- #########################################################################
- # SetUpOutput(pCreateFiles)
- #========================================================================
- # Author: Kevin Avoy
- # Description: Sets up the files required to log TCS records using the FileTool.
- # This will only occur if the Global gFileTooOutput evaluates
- # to true. This 1st attempt at setting up the output files is to
- # read the 'SPEC S&L Prefs' file from the host Preferences folder.
- # If this file does not exist or contain the proper info, a Folder
- # will be created (if it does not already exist) on the root of
- # the boot drive titled "TCSOutput". OutPut files will be created
- # in the folder which are titled with the name of the target
- # and a time stamp. e.g. IIx.1235
- # Parameters: pCreateFiles - Boolean Flag which indicates whether or not
- # to actually create the output files.
- # Returns: Nothing
- # Examples: SetUpOutput(1);
- # Assumptions: Note: Two files are actually created/used. 1 main file and a
- # 'Temp' file. TCS records are written to the 'Temp'
- # file and at the end of the run (SuiteEnd()) the 'Temp'
- # file is appended to the end of the main file and the
- # 'Temp' file is deleted. If the user aborts a test, their
- # partial data will be in the 'Temp' file and the main
- # file will not be altered.
- #========================================================================
- # History:
- # KTA 12/1/93 Not writing total TestCase info to notebooks.
- #########################################################################
- task SetUpOutput(pCreateFiles := 0)
- begin
- if(global gTestCaseLoggingMethod = 1) # User wants to output TCS records using the FileTool
- begin
- DidFileToolInit := InitFileTool(false); # FileTool Initialized properly
- if not (DidFileToolInit)
- begin
- println "Problem initializing FileTool";
- println "WARNING: We cannot write Test Case records using FileTool";
- end;
- else
- begin
- ## Prefs file - need to read Path and RunID
- PrefsFolder := FindFolder("pref")[2];
-
- global SLPrefsFile := "{PrefsFolder}SPEC S&L Prefs:SPEC S&L Preferences";
- isPrefs := FileExists( SLPrefsFile );
-
- if(isPrefs[2] = 1)
- begin
- ## Read Path and RunID from Prefs File
- theLine := ReadLine2( SLPrefsFile, 0); # First line of Prefs contains Path
- if(theLine)
- begin
- global gTCSOutputPath := StripCarriageReturn(theLine);
-
- if(gTCSOutputPath)
- y := card(gTCSOutputPath);
-
- theLine2 := ReadLine2( SLPrefsFile ,y+1); # Second line of Prefs contains RunId
- if(theLine2)
- begin
- RunID := StripCarriageReturn(theLine2);
-
- global gFileToolOutputFile := "{gTCSOutputPath}{global gMachineName}.{RunId}.TCS";
- global gFileToolOutputTempFile := "{gTCSOutputPath}{global gMachineName}.{RunId}.temp";
- fileToolFlag := 1;
- end;
- end;
- end;
- else
- LogStr("The 'SPEC S&L Prefs' file does not exist");
-
-
- ## If couldn't read Prefs file correctly, set new outputFile based on:
- ## MachineName and Time of Day
- if not ( fileToolFlag ) # In case something failed above, write to a unique file on root of boot
- begin
- match[time h:?TheHour];
- SysFolderReturn := FindFolder("macs")[2]; # Get System folder path
- bootVol := StringUntilChar(SysFolderReturn, ':', 1); # Strip so only has boot vol
- global gTCSOutputPath := "{bootVol}TCSOutput:";
- IsOutput := FileExists(gTCSOutputPath);
- if((IsOutput[1] <> 0) and (IsOutput[2] <> 1))
- CreateFolder(gTCSOutputPath);
- else begin
- #println "The output Folder '{gTCSOutputPath}' already exists";
- end;
-
- global gFileToolOutputFile := "{gTCSOutputPath}{global gMachineName}.{TheHour}.TCS";
- global gFileToolOutputTempFile := "{gTCSOutputPath}{global gMachineName}.{TheHour}.temp";
- end;
-
- if(pCreateFiles) # Do we want to actually create the output folder/files
- begin
- # Create a main file for all targets all suites, and a Temp to write individual suite Data, before catenation
- if (ExistsOrCreate( global gFileToolOutputFile ))
- begin
- TempFile := ExistsOrCreate( global gFileToolOutputTempFile );
- if( TempFile) # Could we enable the file to exist
- begin
- if( TempFile = 1) # File already Existed
- EraseFile( global gFileToolOutputTempFile );
- end;
- else
- begin
- Println "Error : Temp file does not exist - turning FileTool Logging - OFF";
- global gTestCaseLoggingMethod := 0; # Turn test case logging - OFF
- end;
- end;
- else
- begin
- Println "Error : Output file does not exist - turning FileTool Logging - OFF";
- global gTestCaseLoggingMethod := 0; # Turn test case logging - OFF
- end;
- end;
- end;
- end;
- end;
-
- #########################################################################
- # FillTCSId( pTCSId )
- #========================================================================
- # Author: naga
- # Description: Start TCS Record.
- # Parameters: pTCSId
- # Returns: new complete TCSId ( a list of 4 elements)
- # Examples: newId := FillTCSId( oldId );
- # Assumptions: None
- #========================================================================
- # History:
- #########################################################################
- TASK FillTCSId( pTCSId )
- begin
- if (TypeOf(pTCSId) <> 'list')
- begin
- println "!!!! Improper TCS Id -- ", pTCSId, " !!!!" ;
- if (TypeOf(pTCSId) = 'integer') #if using old style numeric Id
- return { pTCSId, global kTCSetDefault, global kTCTypeDefault, global kTCOwnerDefault };
- else
- return { 0, global kTCSetDefault, global kTCTypeDefault, global kTCOwnerDefault };
- end;
- else #if (TypeOf(pTCSId) = 'list')
- begin
- if (IsUndefined(pTCSId[1]))
- pTCSId := Insert(0, 1, pTCSId);
- else if (TypeOf(pTCSId[1]) <> 'integer')
- pTCSId := replace(0, 1, pTCSId);
-
- if (IsUndefined(pTCSId[2]))
- pTCSId := Insert(global kTCSetDefault, 2, pTCSId);
- else if (TypeOf(pTCSId[2]) <> 'string')
- pTCSId := replace(global kTCSetDefault, 2, pTCSId);
-
- if (IsUndefined(pTCSId[3]))
- pTCSId := Insert(global kTCTypeDefault, 3, pTCSId);
- else if (TypeOf(pTCSId[3]) <> 'string')
- pTCSId := replace(global kTCTypeDefault, 3, pTCSId);
-
- if (IsUndefined(pTCSId[4]))
- pTCSId := Insert(global kTCOwnerDefault, 4, pTCSId);
- else if (TypeOf(pTCSId[4]) <> 'string')
- pTCSId := replace(global kTCOwnerDefault, 4, pTCSId);
-
- return pTCSId;
- end;
- end;
-
- #########################################################################
- # TCSStart(pTCSId, pTextDesc, pAppName)
- #========================================================================
- # Author: GS (x25506)
- # Description: Start TCS Record.
- # Parameters: pTCSId - The TCS Id that results are being recorded for (list)
- # 1st element - Test Case number (integer)
- # 2nd element - Test Case Set (string)
- # 3rd element - Test Case Type (string)
- # 4th element - Test Case Owner (string)
- # pTextDesc - string that describes the Test Case
- # pAppName - defaults to gAppTitle, otherwise the name of the
- # application the Test Case applies to
- # Returns: Nothing
- # Examples: TCSStart();
- # Assumptions: None
- #========================================================================
- # History:
- # KTA 8/20/93 If TCSAttempted is undefined call InitTCSLogging()
- # KTA 12/01/93 Added gTCSStartHook1, and moved ApplicationVerification
- # so it will be called even if gDBLogging is off
- #########################################################################
- TASK TCSStart(pTCSId, pTextDesc, pAppName := global gAppTitle)
- begin
- if(global gTCSStartHook1)
- Call(gTCSStartHook1);
-
- if (global gDBLogging)
- begin
- global TCSAttempted;
-
- if (IsUndefined(TCSAttempted))
- InitTCSLogging(0);
-
- TCSAttempted := TCSAttempted + 1;
- pTCSId := FillTCSId( pTCSId );
- if(global gAppIdentifier)
- pAppName := gAppIdentifier;
- if not (pAppName) # If AppName is not defined, define it.
- Match[application t:?pAppName];
- TCSBeginTime := Timer();
- thisTCS := {pTCSId, pTextDesc, pAppName, TCSBeginTime};
- #println "TCSStart ", pTCSId;
- TCSPush(thisTCS);
- end;
-
- if (global gAppVerify) # Verify that the correct Application is running
- ApplicationVerification(1);
- end;
-
- #########################################################################
- # TopOfTCSStack()
- #========================================================================
- # Author: Kevin Avoy (x45604)
- # Description: Returns the top element of TCS stack.
- # Parameters: nothing
- #
- # Returns: thisTCS - TCS from the top of the stack
- # Examples: myTCS := TopOfTCSStack();
- # Assumptions: None
- #========================================================================
- # History:
- #
- #########################################################################
- task TopOfTCSStack()
- begin
- global gTCSList;
- thisTCSPos := card(gTCSList);
- thisTCS := gTCSList[thisTCSPos];
- return(thisTCS);
- end;
-
- #########################################################################
- # TCSPop()
- #========================================================================
- # Author: Kevin Avoy (x45604)
- # Description: Pops the top element from the stack and returns it.
- # Parameters: nothing
- #
- # Returns: thisTCS - TCS record from the top of the stack
- # Examples: myTCS := TCSPop();
- # Assumptions: None
- #========================================================================
- # History:
- #
- #########################################################################
- task TCSPop()
- begin
- global gTCSList;
- thisTCSPos := card(gTCSList);
- thisTCS := gTCSList[thisTCSPos];
- gTCSList := remove(thisTCSPos, gTCSList); #decrement the stack
- #println gTCSList;
- return(thisTCS);
- end;
-
- #########################################################################
- # TCSPush(pThisTCS)
- #========================================================================
- # Author: Kevin Avoy (x45604)
- # Description: Push <pThisTCS> onto the stack
- # Parameters: pThisTCS - TCS record to push onto the stack
- #
- # Returns: Nothing
- # Examples: TCSPush(myTCS);
- # Assumptions: None
- #========================================================================
- # History:
- #
- #########################################################################
- task TCSPush(pThisTCS)
- begin
- global gTCSList;
-
- thisTCSPos := card(gTCSList) + 1;
- gTCSList := insert(pThisTCS, thisTCSPos, gTCSList); #add thisTCS to the end of the stack
- if(global gDebugFlag)
- println"TCSPush ",gTCSList;
- end;
-
- #########################################################################
- # TCSEnd(pTCSId,pResultCode, pErrStr, pTCSVal, pTCSStr, pResultStr, pExceptionFlag)
- #========================================================================
- # Author: GS (x25506)
- # Description: This task is called when the functionality of the pending TCS
- # is complete. It will pop the top TCS record from the TCS stack,
- # check to insure the TCS numbers match. If the result code (<pResultCode>)
- # is 0 a check will be done to insure no unexpected dialogs are present.
- # A call to ExceptionHandler() is made to insure that no VU errors were
- # encountered. Then the appropriate output task is called to output the
- # data.
- # Parameters: pTCSId - The TCS Id that results are being recorded for (list)
- # 1st element - Test Case number (integer)
- # 2nd element - Test Case Set (string)
- # 3rd element - Test Case Type (string)
- # 4th element - Test Case Owner (string)
- # pResultCode - The result of the TCS on top of Stack (Lifo)
- # pErrStr - Reason for failure if known.
- # pTCSVal - Any value a TCS needs to return for additional info.
- # pTCSStr - Any string a TCS needs to return for additional info.
- # pResultStr - A string the TCS can return results in.
- # pExceptionFlag - incase of critical error we may need to dump the stack
- # - 'NoRecursion' this will avoid recursion
- # - any integer will bail the suite with the value of the integer
- # Returns: Nothing
- # Examples: TCSEnd();
- # Assumptions: None
- #========================================================================
- # History:
- # KTA 7/6/93 If not gDBLogging TCSEnd will not do anything
- # KTA 7/20/93 Failreason was being reinitialized thus destroying any parameter data.
- # KTA 7/28/93 Added gTCSEndHook1 and reworked dialogHandler
- # KTA 8/05/93 Support for new Pheonix data format
- # KTA 8/09/93 Added pDumpStack parameter
- # KTA 8/24/93 TCS stack parity check
- # KTA 12/01/93 moved gTCSEndHook1 so it will be called even if gDBLogging is off.
- # KTA 12/1/93 Not writing total TestCase info to notebooks.
- # KTA 12/13/93 Changed parameter pDumpStack to pExceptionFlag
- #########################################################################
- TASK TCSEnd(pTCSId := {}, pResultCode := '', pErrStr := '', pTCSVal := 0, pTCSStr := '', pResultStr := '', pExceptionFlag := '')
- begin
- if(global gTCSEndHook1)
- Call (gTCSEndHook1, TopOfTCSStack());
-
- if (global gDBLogging)
- begin
- eTCSTime := 0;
-
- rightNow := Timer(); # Current Time
- thisTCS := TCSPop(); # Pop the current TCS
- #### TCS Parity check - are we working with the right TCS???
- StackTCSId := thisTCS[1];
- if (StackTCSId[1] <> pTCSId[1]) or (StackTCSId[2] <> pTCSId[2])
- begin
- println " TCS mismatched : TOS - ", StackTCSId, ", Passed in - ", pTCSId;
- println " Exiting Script - the TCS stack is unbalanced";
- call (global gExitVU);
- end;
-
- eTCSTime := ETime(thisTCS[4], rightNow); # Elapsed Time
-
- if not(pExceptionFlag = 'NoRecursion') and (global gExceptionHandler) # Insure that we are not calling recursively
- call (gExceptionHandler,, eTCSTime, pErrStr);
-
- if (typeOf(pResultCode) = 'string') # if embedded task returns string, i.e. selectmenuitem
- pResultCode:=1; # set pResultCode to success
-
- if (pResultCode = 0) and not(pExceptionFlag = 'NoRecursion') # do we to dialogCheck for pResultCode < 0
- begin
- for i := 1 to 6
- begin
- myErrStr := DialogHandler();
- if(TypeOf(myErrStr) = 'string')
- pErrStr := pErrStr + myErrStr;
- else if(myErrStr = -1)
- i := 7;
-
- if(i = 6)
- begin
- pErrStr := "Failed in infinite dialog check - {pErrStr}";
- pExceptionFlag := 0; # Abort suite fail with a 0
- end;
- end;
- end;
- else if (pResultCode < 0) # QuickStats
- global TCSNotAvail := TCSNotAvail + 1;
- else if (pResultCode > 0)
- global TCSPassed := TCSPassed + 1;
-
- if(global gDebugFlag)
- println"TCSend ",gTCSList;
-
- ### Output database records to the NoteBook
- if(global gNoteBookOutput)
- PrintTCSRecord(thisTCS, pResultCode, pResultStr, pTCSVal, pTCSStr, pErrStr, eTCSTime);
-
- ### Output database records using FileTool
- if(global gTestCaseLoggingMethod = 1)
- LogTCSRecord(thisTCS, pResultCode, pResultStr, pTCSVal, pTCSStr, pErrStr, eTCSTime);
-
- if (not(pExceptionFlag = 'NoRecursion') and not(pExceptionFlag = '')) # Fatal Error
- CleanAbort(pErrStr,,pExceptionFlag);
-
- end;
- end; # TCSEnd()
-
-
- #########################################################################
- # ExceptionHandler(pTheError := 0, pElaspedTCSTime, pFailReason)
- #========================================================================
- # Author: GS (x25506)
- # Description: Handle Exceptions. It currently handlessome VU errors and
- # some TCS related errors. (This will change). If a fatal
- # error occured CleanAbort() will be called to dumped the
- # TCS Stack and exit the script
- # Parameters: pTheError - Error code if its a TCS related error. If this
- # evaluates to 0 it will be reset with a call to ScriptError()
- # pElaspedTCSTime - The elapsed time it took to complete the pending
- # TCS.
- # pFailReason - A reason for calling ExceptionHandler() if known,
- # (normally TCS related errors if this is defined).
- # Returns: Nothing
- # Examples: ExceptionHandler();
- # Assumptions: None
- #========================================================================
- # History:
- #
- #########################################################################
- task ExceptionHandler(pTheError := 0, pElaspedTCSTime := 0, pFailReason := "")
- begin
- suitCompletion := 0;
- if (global gExHandling)
- begin
- if (pTheError = 0)
- begin
- tempTimeOut := NetworkTimeout(10);
- tempRetries := NetworkRetries(2);
-
- match[target a:?dummyVar s:?dummyVar2];
- pTheError := scriptError();
-
- NetworkTimeout(tempTimeOut);
- NetworkRetries(tempRetries);
- end;
-
- if(gDebugFlag)
- println "ScriptError: ",pTheError;
-
- if not(pTheError)
- return(0);
-
- theFailReason := "Unaccounted Error " + "{pTheError}";
- if (pTheError = -1100)
- begin
- println "!!!!!! Target Failure (ScriptError = -1100) !!!!!!!";
- theFailReason := "Target Failure (ScriptError = -1100)";
- suitCompletion := -2;
- end;
-
- else if (pTheError = -1)
- begin
- println "!!!!!! Unknown VU Error (ScriptError = -1) !!!!!!!";
- theFailReason := "Unknown VU Error (ScriptError = -1)";
- end;
-
- else if (pTheError = -2)
- begin
- println "!!!!!! VU Program Error (ScriptError = -2) !!!!!!!";
- theFailReason := "VU Program Error (ScriptError = -2)";
- end;
-
- else if (pTheError = -69)
- begin
- println "!!!!!! We're off track !!!!!!!";
- theFailReason := "We're off track (ScriptError = -69)";
- end;
-
- theFailReason := pFailReason + " *" + theFailReason;
-
- CleanAbort(theFailReason, pElaspedTCSTime, suitCompletion);
- end;
- end;
-
-
- #########################################################################
- # CleanAbort(pFailReason, pElapsedTCSTime := 0, pSuiteComplete := 0)
- #========================================================================
- # Author: GS (x25506)
- # Description: Dumps the TCS stack appropriately failing the TCS's that
- # couldn't be completed. Then releases the target, and exits
- # the script
- # Parameters: pFailReason - Reason for failing TCS.
- # pElapsedTCSTime - Time it took for TCS to complete
- # pSuiteComplete - Completion Code for Suite.
- # Returns: Nothing
- # Examples: CleanAbort();
- # Assumptions: None
- #========================================================================
- # History:
- # KTA 9/1/93 Updated so only the TCS record at the top of the stack will
- # fail with a 0, all others fail with -1 (expected fail)
- # KTA 12/13/93 Moved functionality of clearing the stack to it's own task - ClearStack().
- #########################################################################
- task CleanAbort(pAbortReason := '', pElapsedTCSTime := 0, pSuiteComplete := 0)
- begin
- println "Aborting Script";
-
- ClearStack(pAbortReason);
-
- println "Releasing Target!!";
- releaseTarget();
-
- SuiteEnd(pSuiteComplete);
-
- call (global gExitVU);
- end;
-
- #########################################################################
- # ClearStack(pFailReason)
- #========================================================================
- # Author: Kevin Avoy (x4-5604)
- # Description: Pops all of the TCSes from the TCS stack appropriately failing
- # them with an error code of -1
- # Parameters: pFailReason - Reason for failing TCS that is at the top of the stack.
- # Returns: Nothing
- # Examples: ClearStack('I wanted to');
- # Assumptions: None
- #========================================================================
- # History:
- # KTA 12/13/93 Created
- #########################################################################
- TASK ClearStack(pAbortReason := '')
- begin
- count := 0;
- for each item in global gTCSList
- begin
- count := count + 1;
- thisTCS := gTCSList[count];
- TCSNum := thisTCS[1];
- if (count = 1) # The current fail reason should only belong to the top of the stack
- failReason := pAbortReason;
- else
- failReason := "The previous TCS created a critical failure";
-
- TCSEnd(TCSNum, -1, failReason,,,,'NoRecursion');
- end;
- end;
-
- #########################################################################
- # SuiteStart(pScriptName, pScriptParamList, pScriptVersion)
- #========================================================================
- # Author: GS (x25506)
- # Description: Start Suite Record.
- # Parameters: pScriptName - Name of the current script
- # pScriptParamList - list of VU parameters for the current execution
- # pScriptVersion - version of the current script
- # Returns: Nothing
- # Examples: SuiteStart("MacDraw.vu", {1}, '1.1.2');
- # Assumptions: None
- #========================================================================
- # History:
- # KTA 8/5/93 Rewrote calling PrintSuiteHeader
- # KTA 8/9/93 Added ability to output DB Records to Notebook and/or with FileTool
- # KTA 9/2/93 Not writing to string 'FileTool output' to prefs file anymore.
- # KTA 12/1/93 Not writing to any suite info to notebooks.
- #########################################################################
- TASK SuiteStart(pScriptName := '', pScriptParamList := {}, pScriptVersion := 'xxx')
- begin
- global gAppTitleSaveOff := global gAppTitle; # Used in SuiteEnd() for lab report
- global gSuiteStarted := 1; # Indicates the suite was started/used in SuiteEnd
- if (global gDBLogging)
- begin
- InitTCSLogging(global gTestCaseLoggingMethod); # Initialize all globals and <Constants>
-
- ### Output database records using FileTool
- if(global gTestCaseLoggingMethod = 1)
- begin
- LogStr( "TCS Records will be written to the file - '{global gFileToolOutputFile}'");
- LogSuiteHeader(pScriptName, pScriptVersion, "{pScriptParamList}");
- myreturn := WriteToFile(global gFileToolOutputTempFile, " TEST CASE [∂n");
- if (myReturn[1] <> 0) # we cannot write to our file
- println "WARNING: Problem writing to output file using FileTool, TCSOutput is not being written";
- end;
- else
- LogStr( "TCS Records are not being written with the FileTool");
-
- global gFirstTCS := true;
- end;
- BeginTimer();
- end;
-
-
- #########################################################################
- # SuiteEnd(pCompletionCode)
- #========================================================================
- # Author: GS (x25506)
- # Description: End Suite Record.
- # Parameters: pCompletionCode - Code which indicates success of suite
- # 1 - Completed successfully
- # 0 - Completed unsuccessfully
- # Returns: Nothing
- # Examples: SuiteEnd(1);
- # Assumptions: none
- # Additional information concerning global gSuiteFooterHook:
- # gSuiteFooterHook has been provided to allow additonal information to be written
- # to the suite block. If there is additonal information that needs to be written to
- # the suite block, gSuiteFooterHook needs to be defined as a task reference that
- # returns a formatted string. The string should be defined as 1 or more Phoenix data fields.
- # Each new field should be in the form of "∂t∂t<FieldLabel>:∂t<FieldData>∂n"
- # If there are multiple fields that need to be returned, they should be
- # concatenated and returned as a single string. Note: the default setting is that
- # gSuiteFooterHook is undefined and thus nothing will be added to the suite footer
- # unless explicitly defined.
- #========================================================================
- # History:
- # KTA 7/13/93 Added TCSExpCount as per Gil
- # KTA 8/4/93 support for new Pheonix data format
- # KTA 12/1/93 Not writing to any suite info to notebooks.
- # KTA 12/2/93 Added gSuiteFooterHook.
- #########################################################################
- TASK SuiteEnd(pCompletionCode := 1)
- begin
- if(global gSuiteStarted) # Suite was started.
- begin # Indicates that SuiteStart was called
- if(pCompletionCode = 1)
- Endtimer();
-
- if (global gDBLogging)
- begin
- tab := "∂t";
- AdditionalSuiteInfo := '';
-
- global TCSAttempted, TCSPassed,gAppTitleSaveOff,TCSNotAvail, TCSExpCount;
-
- suiteEndTime := GetCurrentTime(1,0);
-
- match[time d:?day m:?month y:?year];
- suiteEndDate := "{month}/{day}/{year}";
-
- ### Output database records using FileTool
- if(global gTestCaseLoggingMethod = 1)
- begin
- TCSTrailerString := " ]∂n"; # TCSTrailer
- EndDateString := " EndDate: {suiteEndDate}∂n";
- EndTimeString := " EndTime: {suiteEndTime}∂n";
- SuiteValString := " SuiteVal: {pCompletionCode}∂n";
-
- if (global gSuiteFooterHook) # Hook to add info to the suite footer (see task header for more details.)
- AdditionalSuiteInfo := Call (gSuiteFooterHook);
-
- SuiteTrailerString := " &&∂n"; # SuiteTrailer
- theString := TCSTrailerString + EndDateString + EndTimeString + SuiteValString + AdditionalSuiteInfo + SuiteTrailerString;
- WriteToFile(global gFileToolOutputTempFile, theString);
-
- AppendData := AppendFile( global gFileToolOutputFile, gFileToolOutputTempFile);
- if(AppendData[1] <>0)
- begin
- println "Sorry, error appending to main file - global gFileToolOutputFile";
- Println "Error := ", AppendData[1], AppendData[3];
- end;
- else
- DeleteFile( gFileToolOutputTempFile ); # Clean Up - delete the temp files
- end;
- # This is for MatrixCheck - QuickStats
- println "¬ ",gAppTitleSaveOff, tab, TCSExpCount, tab, TCSPassed, tab, TCSAttempted, tab, TCSNotAvail, tab, pCompletionCode, tab, tab, suiteEndDate, tab, SuiteEndTime;
- end;
- end; # The suite was never started
- end;
-
- #########################################################################
- # ApplicationVerification(pAppVerify)
- #========================================================================
- # Author: Kevin Avoy (x45604)
- # Description: Verify that the current Application is the same as the global
- # gAppTitle. If not successfull, Abort of script will occur thru
- # ExceptionHandler().
- # Parameters: pAppVerify - 1 := will make the check
- # 0 := will not make the check
- # Returns: nothing
- # Examples: ApplicationVerification(1);
- # Assumptions: None
- #========================================================================
- # History:
- # KTA 9/14/93 If gAppTitle is not defined turn off Application Verification
- # KTA 9/20/93 Retry counter was decremented and it should have been incremented
- # KTA 9/22/93 theAppTitle was undefined
- # KTA 12/06/93 if gApptitle = 'Unknown' turn off gAppVerify
- #########################################################################
- task ApplicationVerification(pAppVerify := 0)
- begin
- if (pAppVerify) and (Global gAppVerify)
- begin
- if not(global gAppTitle) or (gApptitle = 'Unknown')
- begin
- LogStr("The global 'gAppTitle' was not defined turning OFF the Application Verfication scheme");
- global gAppVerify := 0;
- end;
- else
- begin
- retry := 0;
- while not( match[application t:gAppTitle]) # assume target crashed if app name not match
- begin
- if(global gExceptionHandler)
- call (gExceptionHandler,,,"LogStr couldn't match target");
- if (retry < 2)
- begin
- if (match[menuitem t:gAppTitle m:[menu t:?Menutitle]])
- begin
- Select[MenuItem t:gAppTitle m:[menu t:Menutitle]];
- wait(3);
- end;
- retry := retry + 1;
- end;
- else
- begin
- match[application t:?theAppTitle];
- PressKey K:{CommandKey};
- Type k: {'q'}; # Quit
- ReleaseKey K:{CommandKey};
- Println "*** Failed Application Verification - aborting script and typing key Equivalent 'Q'";
- Println;
- CleanAbort("Failed app verification scheme - *** Current app: '{theAppTitle}' *** Expected app: '{gAppTitle}'");
- end;
- end;
- end;
- end;
- end; # ApplicationVerification()
-
-
- #########################################################################
- # PrintTCSRecord(pTCSRecord, pResultCode, pResultStr, pTCSVal, pTCSStr, pErrStr, pElapsedTime)
- #========================================================================
- # Author: Kevin Avoy (x4-5604)
- # Description: Prints TCS record information to the notebook.
- # Parameters: pTCSRecord - The current TCS Record from top of stack
- # pResultCode - Result of the TCS
- # pResultStr - String provided for returning results
- # pTCSVal - field for TCS specific values
- # pTCSStr - field for TCS specific strings
- # pErrStr - String for explaining failure
- # pElapsedTime - Elapsed time
- # Returns: Nothing
- # Examples: PrintTCSRecord();
- # Assumptions: None
- #========================================================================
- # History:
- # KTA 8/09/93 Added check to see if field exist before printing it.
- # KTA 9/30/93 Fixed a bug where pTCSVal wouldn't print if is was an integer
- # KTA 9/30/93 Print all fields for gNoteBookOutput = 2 if they exist
- # KTA 12/01/93 Con no longer print complete Test Case output to notebooks
- #########################################################################
- task PrintTCSRecord(pTCSRecord, pResultCode, pResultStr, pTCSVal, pTCSStr, pErrStr, pElapsedTime)
- begin
- if (gNoteBookOutput)
- begin
- Print " •TCS - ", pTCSRecord[1], ", ",pTCSRecord[2], ", ", pResultCode;
- if(pResultStr)
- print ", ", pResultStr;
- if(pTCSVal)
- print ", ", pTCSVal;
- if(pTCSStr)
- print ", ", pTCSStr;
- if(pErrStr)
- print ", ", pErrStr;
-
- println;
- end;
- end;
-
- #########################################################################
- # LogSuiteHeader(pScriptName, pScriptVersion, pScriptParameterList)
- #========================================================================
- # Author: Kevin Avoy (x4-5604)
- # Description: Outputs suite header information utilizing the FileTool
- # Parameters: pScriptName - Name of the current script
- # pScriptVersion - Version of the current script
- # pScriptParameterList - Parameters to the current script
- # Returns: Nothing
- # Examples: LogSuiteHeader("MacDraw", '1.0',{1});
- # Assumptions: None
- #========================================================================
- # History:
- # KTA 9/23/93 Commented out Desc field as we can't get any useful info for this field yet.
- #########################################################################
- task LogSuiteHeader( pScriptName := 'na', pScriptVersion := 'na', pScriptParameterList := "")
- begin
- global gAppTitle, gAppVersion, gSeedValue;
- SuiteHeaderString := "∂n∂n";
-
-
- theMachineState := MachineState();
- TargetName := assoc('TargetName', theMachineState);
- TargetNameString := " TargetName: {TargetName}∂n"; # TargetName
- SuiteHeaderString := SuiteHeaderString + TargetNameString;
-
- if not(gAppTitle)
- gAppTitle := 'Unknown';
- AppNameString := " AppName: {gAppTitle}∂n"; # AppName
- SuiteHeaderString := SuiteHeaderString + AppNameString;
-
- if(gAppVersion)
- begin
- AppVersionString := " AppVers: {gAppVersion}∂n"; # AppVersion
- SuiteHeaderString := SuiteHeaderString + AppVersionString;
- end;
-
- SuiteNameString := " SuiteName: {pScriptName}∂n"; # ScriptName
- SuiteHeaderString := SuiteHeaderString + SuiteNameString;
-
- SuiteVersionString := " SuiteVers: {pScriptVersion}∂n"; # ScriptVersion
- SuiteHeaderString := SuiteHeaderString + SuiteVersionString;
-
- match[time d:?day m:?month y:?year];
- suiteStartDate := "{month}/{day}/{year}";
- StartDateString := " StartDate: {SuiteStartDate}∂n"; # SuiteStartDate
- SuiteHeaderString := SuiteHeaderString + StartDateString;
-
- suiteStartTime := GetCurrentTime(1,0);
- StartTimeString := " StartTime: {SuiteStartTime}∂n"; # SuiteStartTime
- SuiteHeaderString := SuiteHeaderString + StartTimeString;
-
- #DescString := " Desc: We don't know∂n"; # Desc
- #SuiteHeaderString := SuiteHeaderString + DescString;
-
- SeedValueString := " SeedValue: {gSeedValue}∂n"; # SeedValue
- SuiteHeaderString := SuiteHeaderString + SeedValueString;
-
- # Now write it off to file (since VU strings can't be longer than 2000 chars)
- WrittenFile := WriteToFile(global gFileToolOutputTempFile, SuiteHeaderString);
- If(WrittenFile[1] <> 0)
- begin
- Println "!@#$% An error occured while writing the file";
- Println "Error", WrittenFile[1], WrittenFile[3];
- global gTestCaseLoggingMethod := 0; # Turn FileTool output - OFF
- end;
- SuiteHeaderString := ""; # re-initialize to null
-
- drawMethod := "gDrawLevel := {global gDrawLevel}; ";
- WindowMethod := "gWindowLevel := {global gWindowLevel}; ";
- FontMethod := "gFontLevel := {global gFontLevel};";
- globList := drawMethod + WindowMethod + FontMethod;
- ScriptParamsString := " SuiteParams: {pScriptParameterList}; {globList}∂n";# ScriptParameterList & Globals
- SuiteHeaderString := SuiteHeaderString + ScriptParamsString;
-
- AddrMode := assoc('AddrMode', theMachineState);
- AddrModeString := " AdMode32: {AddrMode}∂n"; # AddrMode
- SuiteHeaderString := SuiteHeaderString + AddrModeString;
-
- LogicalMem := assoc('LogicalMem', theMachineState);
- LogicalMemString := " LogicalMem: {LogicalMem}∂n"; # LogicalMem
- SuiteHeaderString := SuiteHeaderString + LogicalMemString;
-
- PhysicalMem := assoc('PhysicalMem', theMachineState);
- PhysicalMemString := " PhysicalMem: {PhysicalMem}∂n"; # PhysicalMem
- SuiteHeaderString := SuiteHeaderString + PhysicalMemString;
-
- VM := assoc('VM', theMachineState);
- VMString := " VM: {VM}∂n"; # VM
- SuiteHeaderString := SuiteHeaderString + VMString;
-
- FileSharing := assoc('FileShare', theMachineState);
- FileSharingString := " FileShare: {FileSharing}∂n"; # FileSharing
- SuiteHeaderString := SuiteHeaderString + FileSharingString;
-
- caches := assoc('cache', theMachineState);
- CacheString := " Cache: {caches}∂n"; # cache
- SuiteHeaderString := SuiteHeaderString + CacheString;
-
- SystemArchitecture := assoc('SystemArch', theMachineState);
- SystemArchitectureString := " SystemArch: {SystemArchitecture}∂n";
- SuiteHeaderString := SuiteHeaderString + SystemArchitectureString; # SystemArchitecture
-
- SuiteHeaderString := SuiteHeaderString + "∂n" ;
- WrittenFile := WriteToFile(global gFileToolOutputTempFile, SuiteHeaderString);
- If(WrittenFile[1] <> 0)
- begin
- Println "!@#$% An error occured while writing the file";
- Println "Error", WrittenFile[1], WrittenFile[3];
- global gTestCaseLoggingMethod := 0; # Turn FileTool output - OFF
- end;
- end;
-
- #########################################################################
- # LogTCSRecord(pTCSRecord, pResultCode, pResultStr, pTCSVal, pTCSStr, pErrStr, pElapsedTime)
- #========================================================================
- # Author: Kevin Avoy (x4-5604)
- # Description: Outputs TCS records utilizing the FileTool.
- # Parameters: pTCSRecord - The current TCS Record from top of stack
- # pResultCode - Result of the TCS
- # pResultStr - String provided for returning results
- # pTCSVal - field for TCS specific values
- # pTCSStr - field for TCS specific strings
- # pErrStr - String for explaining failure
- # pElapsedTime - Elapsed time
- # Returns: Nothing
- # Examples: LogTCSRecord(thisTCS,1);
- # Assumptions: None
- #========================================================================
- # History:
- # KTA 9/14/93 If trouble with Filetool turn off fileToolOutput
- #########################################################################
- task LogTCSRecord(pTCSRecord, pResultCode, pResultStr, pTCSVal, pTCSStr, pErrStr, pElapsedTime)
- begin
- TCSString := '';
- global gFirstTCS;
- if not(gFirstTCS)
- TCSString:= TCSString + " &&∂n";
- else
- gFirstTCS := false;
-
-
- thisTCSNo := pTCSRecord[1][1];
- thisTCSSet := pTCSRecord[1][2];
- thisTCSType := pTCSRecord[1][3];
- thisTCSOwner := pTCSRecord[1][4];
- thisTCSDesc := pTCSRecord[2];
- TCSString := TCSString + " TCNo: {thisTCSNo}∂n";
- TCSString := TCSString + " TCSet: {thisTCSSet}∂n";
- TCSString := TCSString + " TCType: {thisTCSType}∂n";
- TCSString := TCSString + " TCOwner: {thisTCSOwner}∂n";
-
- TCSDescrString := " TCDesc: {thisTCSDesc}∂n";
- TCSString := TCSString + TCSDescrString;
-
- ResultCodeString := " Result: {pResultCode}∂n";
- TCSString := TCSString + ResultCodeString;
-
- if (pResultStr)
- begin
- ResultStrString := " ResultDesc: {pResultStr}∂n";
- TCSString := TCSString + ResultStrString;
- end;
- if (pTCSVal)
- begin
- TCSValString := " NumericVal: {pTCSVal}∂n";
- TCSString := TCSString + TCSValString;
- end;
- if (pTCSStr)
- begin
- TCSStrString := " TextVal: {pTCSStr}∂n";
- TCSString := TCSString + TCSStrString;
- end;
- if (pErrStr)
- begin
- ErrStrString := " ErrDesc: {pErrStr}∂n";
- TCSString := TCSString + ErrStrString;
- end;
- if (pElapsedTime)
- begin
- elapsedTime := " ElapsedTime: {pElapsedTime}∂n";
- TCSString := TCSString + elapsedTime;
- end;
- WrittenFile := WriteToFile(global gFileToolOutputTempFile, TCSString);
- If(WrittenFile[1] <> 0)
- begin
- Println "!@#$% An error occured while writing to the file {gFileToolOutputTempFile}";
- Println "Error", WrittenFile[1], WrittenFile[3];
- global gTestCaseLoggingMethod := 0; # Turn FileTool output - OFF
- end;
- else if(WrittenFile = -50)
- begin
- Println "!@#$% An error occured while writing to the TCS Output file";
- Println "TCS Records will not be written - SuiteStart() was not called prior to making TCS calls";
- global gTestCaseLoggingMethod := 0; # Turn FileTool output - OFF
- end;
- end;
-